﻿using Basic.Cluster.Abstract;
using Basic.Cluster.Manager;
using Consul;
using Microsoft.Extensions.DependencyInjection;

namespace Basic.Cluster.Impl;

public class ConsulDiscover : IDiscover
{
    private ConsulClient _consulClient = null;

    /// <summary>
    /// 添加服务注册
    /// </summary>
    /// <param name="services"></param>
    /// <param name="config"></param>
    /// <returns></returns>
    public void AddRegister(ConsulClient client)
    {
        _consulClient = client;
    }


    public Dictionary<string, AgentService> GetService()
    {
        QueryResult<Dictionary<string, AgentService>> result = _consulClient.Agent.Services().GetAwaiter().GetResult();
        return result.Response;
    }

}